package com.outfood.api.controller;

import com.outfood.common.common.CurrentUser;
import com.outfood.common.common.replay.ReplyCode;
import com.outfood.common.common.response.RestResponse;
import com.outfood.domain.Rule;
import com.outfood.service.IRuleService;
import com.rys.common.enums.SearchTypeEnum;
import com.rys.common.utils.Search;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author huisonglin
 * @Description
 * @PackageName outfood-platform
 * @Package com.outfood.api.controller
 * @Date 2024-03-26 14:17
 * @Version 1.0
 */
@RestController
@Api(value = "RepairRecordController" ,tags = {"规则相关操作类"})
@RequestMapping("/api/rule")
public class RuleController {

    @Resource
    IRuleService ruleService;

    @GetMapping("/update")
    @ApiOperation("修改出餐时间")
    public RestResponse updateRule(@ApiParam("门店ID") @RequestParam Long storeId,@ApiParam("出餐时间") @RequestParam Integer time){

        Rule rule = ruleService.getList(new Search().add("storeId", SearchTypeEnum.EqualTo, storeId)).get(0);
        rule.setTime(time);
        ruleService.update(rule.getId(),rule, CurrentUser.getUserId()+"");
        return new RestResponse(ReplyCode.SYS.SUCCESS,"操作成功");
    }


}
